import { createApp } from "vue";
import Antd from "ant-design-vue";
import "ant-design-vue/dist/antd.css";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "./assets/css/public.css";

import { getInfo } from "@/api/https.js";

const getTime = (time) => {
  const date = new Date(time * 1000);
  const fullYear = date.getFullYear();
  const month =
    date.getMonth() + 1 >= 10
      ? date.getMonth() + 1
      : "0" + (date.getMonth() + 1);
  const dates = date.getDate() >= 10 ? date.getDate() : "0" + date.getDate();
  // const hours = date.getHours();
  // const minutes = date.getMinutes();

  // return `${fullYear}-${month}-${dates} ${hours}:${minutes}`;
  return `${fullYear}-${month}-${dates}`;
};

(async () => {
  let { data } = await getInfo();
  data.imgs = data.imgs.split(",");
  localStorage.setItem("publicInfo", JSON.stringify(data));

  const Vue = createApp(App);
  Vue.config.globalProperties.$getTime = getTime;
  Vue.use(Antd);
  Vue.use(store).use(router).mount("#app");
})();
